﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BestLifePOS_Core.Data.Core;
using BestLifePOS_Core.DomainObjects;
using System.Data.SqlClient;
using System.Data;
using BestLifePOS_Core.Exceptions.DataBase;

namespace BestLifePOS_Core.Data.Commands
{
    class BestLifeInsertDisposalDataAction : BestLifeDataAction<int>
    {
        private Disposal GvDispo;

        public BestLifeInsertDisposalDataAction(Disposal PDispo)
        {
            GvDispo = PDispo;
        }

        public override int Body(SqlConnection PConn)
        {
            try
            {
                SqlCommand LvCommand = new SqlCommand();
                LvCommand.Connection = PConn;
                LvCommand.CommandType = CommandType.StoredProcedure;
                LvCommand.CommandText = "dbo.InsertDispo&&Disposal_Details";


                LvCommand.Parameters.Add(new SqlParameter("@Disp_Id", GvDispo.Dis_Id.ToString()));
                LvCommand.Parameters.Add(new SqlParameter("@PL_Id", GvDispo.PL_Id.ToString()));
             //   LvCommand.Parameters.Add(new SqlParameter("@ProName",GvDispo.PL_Id.ToString())));
                LvCommand.Parameters.Add(new SqlParameter("@Qty", GvDispo.Qty.ToString()));
                LvCommand.Parameters.Add(new SqlParameter("@Description",GvDispo.Description.ToString()));
                LvCommand.Parameters.Add(new SqlParameter("@status", GvDispo.Status.ToString()));
                LvCommand.Parameters.Add(new SqlParameter("@User_Id",GvDispo.User_Id.ToString()));
                LvCommand.Parameters.Add(new SqlParameter("@Date_Create",GvDispo.Date_Create.ToString()));
                LvCommand.Parameters.Add(new SqlParameter("@User_Modify", GvDispo.User_Modify.ToString()));
                LvCommand.Parameters.Add(new SqlParameter("@Date_Modify", GvDispo.Last_Modify.ToString()));

                int LvCount = LvCommand.ExecuteNonQuery();
                return LvCount;

            }
            catch (BestlifeDatabaseException e)
            {
                throw new BestlifeDatabaseException(e);
            }



        }
      

    }
}